const app = getApp();
import grace from "../../../utils/grace.js";

grace.page({
  /**
   * 页面的初始数据
   */
  data: {
  },
  formSubmit(e) {
    let that = this;
    // 用户输入校验
    if (e.detail.value.id_card == '') {
      wx.showToast({
        title: '身份证不能为空',
        icon: 'fail',
        duration: 1500
      })

      return false;
    }

    let token = wx.getStorageSync('token');
    let school_id = wx.getStorageSync('school_id')
    wx.showLoading({
      title: '加载中...',
    })
    let url = app.globalData.api + '/api/v1.0/addChild/' + school_id;
    let params = {
      token: token,
      partner_id: wx.getStorageSync('partner_id'),
      id_card: e.detail.value.id_card
    }
    that.$http.post(url, params).then((res) => {
      if (res.data.code == 0) {
        that.$goBack();
      }else{
        wx.showModal({
          title: '错误',
          content: res.data.msg,
          showCancel: false
        })
      }
      wx.hideLoading();
    })
  }
})